home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 10 Aug 98
- // Author: mw
- //
- // Description:
- // doCopyKeyArgList is the actual proc that is executed from the
- // Edit->Keys->Copy Keys option box or menu.
- //
- // doCopyKeyArgList allows for a variable number
- // or arguments to be passed in through a string array.
- // This is not possible through the fixed-arg proc doCopyKey
- //
- // Input Arguments:
- // $version: The version of this option box. Used to know how to
- // interpret the $args array.
- // "1" : $whichRange, $timeRange, $option, $hierarchy,
- // $doControlPoints, $doShapes, $useChannelBox,
- // $selectionConnection
- // "2" : $options
- //
- // $args
- // Version 1
- // [0] $whichRange 1 : time range all
- // 2 : use playback range
- // 3 : use $timeRange
- // [1] $timeRange startTime:endTime
- // [2] $option keys
- // curve
- // [3] $hierarchy 1 : none
- // 2 : below
- // [4] $doControlPoints 0 / 1
- // [5] $doShapes 0 / 1
- // [6] $useChannelBox 0 / 1
- // [7] $selectionConnection name of selection connection to use
- // unless $options has "bufferCurve" in which
- // case this is the name of the editor
- // Version 2
- // [8] $options a ':' delimited list of options
- // noOptions an empty placeholder
- // bufferCurve create buffer curves
- // Version 3
- // [11] $fromGraphEditor 0 / 1
- // [12] $doDrivenChannels 0 / 1
- //
- // Return Value:
- // The number of curves from which keys were copied.
- //
- global proc int doCopyKeyArgList( string $version, string $args[] )
- {
- int $versionNum = $version;
-
- int $whichRange = $args[0];
- string $timeRange = $args[1];
- string $option = $args[2];
- string $hierarchy = $args[3];
- int $doControlPoints = $args[4];
- int $doShapes = $args[5];
- int $useChannelBox = $args[6];
- string $selectionConnection = $args[7];
- string $options = ($versionNum >= 2 ? $args[8] : "noOptions");
- int $fromGraphEditor = $versionNum >= 3 ? $args[9] : "1";
- int $doDriven = $versionNum >= 3 ? $args[10] : "1";
-
- string $cmd = "copyKey ";
-
- string $realConnection = $selectionConnection;
-
- // Check for the bufferCurve option
- //
- if (match ("bufferCurve", $options) == "bufferCurve") {
- $realConnection = `editor -query -mainListConnection $selectionConnection`;
- // Check to see if we need to create buffer curves
- //
- if (`animCurveEditor -query -showBufferCurves $selectionConnection` == "on") {
- $cmd = "bufferCurve -animation \"keys\" -overwrite false; " + $cmd;
- }
- }
-
- // Get the target objects
- //
- string $members = expandSelectionConnection ($realConnection);
-
- int $needOption = true;
- if( $whichRange == 1 ) {
- $timeRange = ":";
- $needOption = false;
- } else if( $whichRange == 2 ) {
- $timeRange = ( `playbackOptions -q -min` + ":" +
- `playbackOptions -q -max` );
- }
-
- // Check to see if a time range has been specified. If no time range,
- // then we don't add the option, since we're doing all the keyframes
- // and an option makes no sense.
- //
- int $keys = `keyframe -sl -q -kc`;
-
- if( !$fromGraphEditor || ( $keys == 0 )) {
- $cmd = ( $cmd + "-time \"" + $timeRange + "\" " );
-
- if( $fromGraphEditor || $doDriven ) {
- $cmd = ( $cmd + "-float \"" + $timeRange + "\" " );
- }
-
- // If there's a time specified, always add the option
- //
- if( $needOption ) {
- $cmd = ( $cmd + "-option " + $option + " " );
- }
- }
-
- if( !$fromGraphEditor && ( $useChannelBox == 1 ) ) {
- string $syntax[] = keySetOptionBoxCommon( { "copyKey", "unknown",
- "channelBoxSyntax" } );
- if( size( $syntax[0] ) == 0 ) {
- $cmd = "";
- warning( "No channels selected in channel box" );
- } else {
- $cmd = ( $cmd + "-hierarchy " + $hierarchy + " " );
-
- $cmd = $cmd + $syntax[0];
- }
- }
- else if( $members != "" ) {
- // Only add the selection connection to the cmd if
- // there are NO active keys (in the graph editor),
- // or we're not called from the graphEditor.
- //
- if( $keys == 0 || !$fromGraphEditor ) {
- if ($members == "{}") {
- $cmd = "";
- warning ("No objects selected to copy keys");
- }
- else {
- $cmd = ($cmd +
- "-hierarchy " + $hierarchy + " " +
- "-controlPoints " + $doControlPoints + " " +
- "-shape " + $doShapes + " " +
- $members
- );
- }
- }
- }
- else {
- $cmd = ( $cmd +
- "-animation objects " +
- "-hierarchy " + $hierarchy + " " +
- "-controlPoints " + $doControlPoints + " " +
- "-shape " + $doShapes + " " );
- }
-
- if( $cmd == "" ) {
- return 0;
- } else {
- return evalEcho( $cmd );
- }
- }
-
-